/*
 * Copyright 2009 Biz-e (info@biz-e.nl)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.biz_e.gdata.data.contacts;

import nl.biz_e.gdata.data.AbstractBaseManager;
import nl.biz_e.gdata.util.GDataAuthentication;
import nl.biz_e.gdata.util.Utils;

import com.google.gdata.client.contacts.ContactsService;
import com.google.gdata.data.contacts.ContactGroupEntry;
import com.google.gdata.data.contacts.ContactGroupFeed;
import com.google.gdata.util.AuthenticationException;

/**
 * @author Joost A. Bloemsma
 * 
 */
public class ContactGroupsManager extends
        AbstractBaseManager<ContactGroupEntry, ContactGroupFeed> {
    /**
     * 
     */
    public static final String FEEDNAME = "groups";
    private final ContactsService service;

    /**
     * Constructs a new ContactGroupsManager instance
     * 
     * @param authentication
     *            Used for authentication agains the GData Service
     * @param appName
     *            The application name
     * @throws AuthenticationException
     *             If authentication fails
     */
    public ContactGroupsManager(GDataAuthentication authentication,
            String appName) throws AuthenticationException {
        super(authentication, FEEDNAME, ContactGroupFeed.class,
                ContactGroupEntry.class, appName);
        this.service = new ContactsService(this.getAppName());
        this.init();
    }

    /**
     * Constructs a new ContactGroupsManager instance.<br/>
     * The application name must have been set to the static
     * {@link Utils#APPNAME} variable.
     * 
     * @param authentication
     *            Used for authentication agains the GData Service
     * @throws AuthenticationException
     *             If authentication fails
     */
    public ContactGroupsManager(GDataAuthentication authentication)
            throws AuthenticationException {
        this(authentication, Utils.APPNAME);
    }

    private void init() throws AuthenticationException {
        this.setService(service);
    }
}
